<template>
  <BasicCard>
    <BasicVxeTable v-bind="gridOptions"> </BasicVxeTable>
  </BasicCard>
</template>

<script setup lang="ts">
  import { columnsRoving } from '../data'
  import { roundNum } from '@/utils'
  import { getCuXiLianZongHeXinXi } from '@/api/shengChanJianShi'

  const { t } = useI18n()

  const gridOptions = reactive<BasicGridProps>({
    extraConfig: {
      title: t(`custom.满管链条`),
      isCustom: true,
      isExport: false,
      isFilterAndSort: true
    }, // 拓展的配置
    id: `shujubaobiao-zaixianpancun-roving`, // id用于缓存,务必配置
    height: '100%',
    loading: true,
    columns: columnsRoving,
    toolbarConfig: {} // 工具栏
  })

  const getList = () => {
    getCuXiLianZongHeXinXi()
      .then((res: any) => {
        gridOptions.loading = false
        gridOptions.data = res.fullSpinning.map((value) => {
          return {
            materialId: value.materialId,
            materialName: value.materialName,
            weightPerYarn: roundNum(value.weightPerYarn),
            fullSpinningCntInFullSpinningStores: roundNum(
              value.fullSpinningCntInFullSpinningStores
            ),
            fullSpinningWeightInFullSpinningStores: roundNum(
              value.fullSpinningWeightInFullSpinningStores
            ),
            fullSpinningCntInCsSpinningStores: roundNum(value.fullSpinningCntInCsSpinningStores),
            fullSpinningWeightInCsSpinningStores: roundNum(
              value.fullSpinningWeightInCsSpinningStores
            ),
            yarnLength: roundNum(value.yarnLength),
            yarnWeight: roundNum(value.yarnWeight),
            pipeChangedCnt: roundNum(value.pipeChangedCnt),
            pipeChangedWeight: roundNum(value.pipeChangedWeight),
            fullPipeCntInCs: roundNum(value.fullPipeCntInCs),
            fullPipeWeightInCs: roundNum(value.fullPipeWeightInCs),
            weightTotal: roundNum(value.weightTotal)
          }
        })
      })
      .catch(() => {
        gridOptions.loading = false
      })
  }

  onMounted(() => {
    getList()
  })
</script>
